<!--#Include File="../conn.asp" -->
<!--#Include File="comm/inc.asp" -->
<%
'====================================================================
'= Team Elite - Elite Article System
'= Copyright (c) 2005 - 2006 Eason Chan All Rights Reserved.
'=-------------------------------------------------------------------
'= 版权协议：
'=	GPL (The GNU GENERAL PUBLIC LICENSE Version 2, June 1991)
'=-------------------------------------------------------------------
'= 文件名称：/Manager/Admin_UserGroup.asp
'= 摘    要：后台-会员组管理文件
'=-------------------------------------------------------------------
'= 最后更新：eason007
'= 最后日期：2005-10-04
'====================================================================

Call EA_Manager.Chk_IsMaster

If Not EA_Manager.Chk_Power(Admin_Power,"21") Then 
	ErrMsg=str_Comm_NotAccess
	Call EA_Manager.Error(1)
End If

Dim Atcion
Atcion=Request.QueryString ("atcion")

Select Case LCase(Atcion)
Case "add"
	Call Add
Case "save"
	Call Save
Case "del"
	Call del
Case Else
	Call Main
End Select
Call EA_Pub.Close_Obj
Set EA_Pub=Nothing

Sub Main
	Dim List,i
	Dim Temp,ListBlock

	PageContent=Template.LoadTemplate("admin_usergroup_list.htm")

	
	Template.SetVariable "Language_Comm_ListEmpty",str_Comm_ListEmpty,PageContent
	Template.SetVariable "Language_Comm_Bar_Operation",str_Comm_Bar_Operation,PageContent
	Template.SetVariable "Language_Comm_Edit_Operation",str_Comm_Edit_Operation,PageContent
	Template.SetVariable "Language_Comm_Alert_Del_Operation",str_Comm_Alert_Del_Operation,PageContent
	Template.SetVariable "Language_Comm_Del_Operation",str_Comm_Del_Operation,PageContent

	Template.SetVariable "Language_OperationNotice",str_OperationNotice,PageContent
	Template.SetVariable "Language_Group_Help",str_Group_Help,PageContent

	Template.SetVariable "Language_Group_List",str_Group_List,PageContent
	Template.SetVariable "Language_Group_Add",str_Group_Add,PageContent

	Template.SetVariable "Language_Group_Name",str_Group_Name,PageContent
	Template.SetVariable "Language_Group_UserTotal",str_Group_UserTotal,PageContent
	Template.SetVariable "Language_Group_ShowList",str_Group_ShowList,PageContent


	ListBlock=Template.GetBlock("list",PageContent)

	List=EA_M_DBO.Get_Group_List()
	If IsArray(List) Then 
		For i=0 To UBound(List,2)
			Temp=ListBlock

			Template.SetVariable "GroupID",List(0,i),Temp
			Template.SetVariable "GroupName",List(1,i),Temp
			Template.SetVariable "GroupUserTotal",List(2,i),Temp
			If CInt(List(0,i))<=4 Then Template.SetVariable "DelLink","none",Temp

			Template.SetBlock "list",Temp,PageContent
		Next
	End If
	Template.CloseBlock "list",PageContent


	Template.BaseReplace PageContent
	Template.OutStr PageContent
End Sub

Sub Add
	Dim PostId,Temp,i
	Dim GroupName,Setting,IsLogin
	PostId=EA_Pub.SafeRequest(3,"postid",0,0,0)
	
	Temp=EA_DBO.Get_Group_Setting(PostId)
	If IsArray(Temp) Then 
		GroupName=Temp(0,0)
		Setting=Split(Temp(2,0),",")
		IsLogin=Temp(1,0)
	End If
	
	If Not IsArray(Setting) Then Setting=Split("0,0,8|23,1,10,10,1,0,1,0,50,10",",")
	If UBound(Setting)<11 Then Setting=Split("0,0,8|23,1,10,10,1,0,1,0,50,10",",")

	PageContent=Template.LoadTemplate("admin_usergroup_option.htm")

	Template.SetVariable "Language_Comm_Save_Button",str_Comm_Save_Button,PageContent
	Template.SetVariable "Language_Comm_Reset_Button",str_Comm_Reset_Button,PageContent
	Template.SetVariable "Language_Comm_Yes",str_Comm_Yes,PageContent
	Template.SetVariable "Language_Comm_No",str_Comm_No,PageContent

	Template.SetVariable "Language_OperationNotice",str_OperationNotice,PageContent
	Template.SetVariable "Language_Group_Help",str_Group_Help,PageContent

	Template.SetVariable "Language_Group_List",str_Group_List,PageContent
	Template.SetVariable "Language_Group_Add",str_Group_Add,PageContent
	Template.SetVariable "Language_Group_Login_Option",str_Group_Login_Option,PageContent
	Template.SetVariable "Language_Group_Power_Option",str_Group_Power_Option,PageContent

	Template.SetVariable "Language_Group_Name",str_Group_Name,PageContent
	Template.SetVariable "Language_Group_IsLogin",str_Group_IsLogin,PageContent
	Template.SetVariable "Language_Group_Timer",str_Group_Timer,PageContent
	Template.SetVariable "Language_Group_Timer_Option",str_Group_Timer_Option,PageContent
	Template.SetVariable "Language_Group_Timer_Option_Help",str_Group_Timer_Option_Help,PageContent

	Template.SetVariable "Language_Group_Power",str_Group_Power,PageContent
	Template.SetVariable "Language_Group_ViewHide",str_Group_ViewHide,PageContent
	Template.SetVariable "Language_Group_PostReviewForRegLater",str_Group_PostReviewForRegLater,PageContent
	Template.SetVariable "Language_Group_PostReviewForRegLater_Help",str_Group_PostReviewForRegLater_Help,PageContent
	Template.SetVariable "Language_Group_PostVotedForRegLater",str_Group_PostVotedForRegLater,PageContent
	Template.SetVariable "Language_Group_PostVotedForRegLater_Help",str_Group_PostVotedForRegLater_Help,PageContent
	Template.SetVariable "Language_Group_IsReview",str_Group_IsReview,PageContent
	Template.SetVariable "Language_Group_ReviewForManager",str_Group_ReviewForManager,PageContent
	Template.SetVariable "Language_Group_IsPostArticle",str_Group_IsPostArticle,PageContent
	Template.SetVariable "Language_Group_PostForManager",str_Group_PostForManager,PageContent
	Template.SetVariable "Language_Group_DayMaxPost",str_Group_DayMaxPost,PageContent
	Template.SetVariable "Language_Group_FavMax",str_Group_FavMax,PageContent
	Template.SetVariable "Language_Group_FavMax_Help",str_Group_FavMax_Help,PageContent

	Template.SetVariable "GroupID",PostId,PageContent
	Template.SetVariable "GroupName",GroupName,PageContent
	Template.SetVariable "IsLogin_" & Abs(CInt(IsLogin))," checked",PageContent
	Template.SetVariable "IsClose_" & Setting(3)," checked",PageContent
	Template.SetVariable "OpenTime",Setting(2),PageContent
	Template.SetVariable "Power",Setting(0),PageContent
	Template.SetVariable "IsHide_" & Setting(1)," checked",PageContent
	Template.SetVariable "ReviewSplit",Setting(5),PageContent
	Template.SetVariable "VotedSplit",Setting(4),PageContent
	Template.SetVariable "IsReview_" & Setting(6)," checked",PageContent
	Template.SetVariable "ReviewNeedManager_" & Setting(7)," checked",PageContent
	Template.SetVariable "IsPost_" & Setting(8)," checked",PageContent
	Template.SetVariable "PostNeedManager_" & Setting(9)," checked",PageContent
	Template.SetVariable "PostMax",Setting(11),PageContent
	Template.SetVariable "FavMax",Setting(10),PageContent


	Template.BaseReplace PageContent
	Template.OutStr PageContent
End Sub

Sub Del
	Call EA_Pub.Chk_Post
	
	Dim PostId
	PostId=EA_Pub.SafeRequest(3,"postid",0,0,0)
	
	EA_M_DBO.Set_Group_Delete PostId
	
	Set Rs=Nothing
	Call EA_Pub.Close_Obj
	Set EA_Pub=Nothing
	
	Response.Redirect Request.ServerVariables("HTTP_REFERER")
End Sub

Sub Save
	Call EA_Pub.Chk_Post
	
	Dim IsExist
	Dim PostId
	Dim Name,Setting,IsLogin
	
	PostId=EA_Pub.SafeRequest(3,"postid",0,0,0)
	Name=EA_Pub.SafeRequest(2,"name",1,"",0)
	IsLogin=EA_Pub.SafeRequest(2,"islogin",0,0,0)
	
	Setting=EA_Pub.SafeRequest(2,"power",0,0,0)
	Setting=Setting&","&EA_Pub.SafeRequest(2,"ishide",0,0,0)
	Setting=Setting&","&EA_Pub.SafeRequest(2,"opentime",1,"8|23",0)
	Setting=Setting&","&EA_Pub.SafeRequest(2,"isclose",0,0,0)
	Setting=Setting&","&EA_Pub.SafeRequest(2,"vote",0,0,0)
	Setting=Setting&","&EA_Pub.SafeRequest(2,"ping",0,0,0)
	Setting=Setting&","&EA_Pub.SafeRequest(2,"ispl",0,0,0)
	Setting=Setting&","&EA_Pub.SafeRequest(2,"plismanger",0,0,0)
	Setting=Setting&","&EA_Pub.SafeRequest(2,"ispost",0,0,0)
	Setting=Setting&","&EA_Pub.SafeRequest(2,"pismanger",0,0,0)
	Setting=Setting&","&EA_Pub.SafeRequest(2,"favmax",0,0,0)
	Setting=Setting&","&EA_Pub.SafeRequest(2,"daypostmax",0,0,0)
	
	If Len(Name)>50 Or Len(Name)=0 Then 
		ErrMsg="对不起，输入的名称不能为0或超过50个字或含有非法字符！"
		Call EA_Manager.Error(1)
	End If
	
	If Rs.State=1 Then rs.Close
	If PostId<>0 Then
		Sql="Select * From [NB_UserGroup] Where [Id]="&PostId
		rs.Open Sql,Conn,2,2
	Else
		rs.Open "NB_UserGroup",Conn,2,2
		rs.AddNew
	End If
		rs("GroupName")=Name
		rs("IsLogin")=IsLogin
		rs("Setting")=Setting
		rs.update
	Rs.Close:Set Rs=Nothing
	
	Call EA_Ini.WriteNode("GroupSetting","Group_"&PostId,Name&","&IsLogin&","&Setting)
	EA_Ini.Save
	
	Call EA_Pub.Close_Obj
	Set EA_Pub=Nothing
	
	Response.Redirect "admin_usergroup.asp"
End Sub
%>